package com.pipayshop.controller;

import com.pipayshop.entity.ShopTags;
import com.pipayshop.entity.vo.PageDataVO;
import com.pipayshop.entity.vo.ResponseVO;
import com.pipayshop.exception.BusinessException;
import com.pipayshop.service.HotelShopTagsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 实体店的标签 前端控制器
 * </p>
 *
 * @author nws
 * @since 2023-07-25
 */
@Api(value = "实体店标签",tags = "实体店标签")
@RestController
@RequestMapping("/pipayshopapi/shop-tags")
@Slf4j
public class HotelShopTagsController {
    @Autowired
    private HotelShopTagsService tagsService;

    @GetMapping("getShopTagsList")
    @ApiOperation("查询标签列表")
    public ResponseVO getShopTagsList(Integer pageNum, Integer pageSize) {
        try {
            PageDataVO list = tagsService.getShopTagsList(pageNum, pageSize);
            return ResponseVO.getSuccessResponseVo(list);
        } catch (Exception e) {
            e.printStackTrace();
            log.error(e.getMessage());
            throw new BusinessException("label_list_query_failed");
        }
    }
    @GetMapping("getShopTagsById/{shopId}")
    @ApiOperation("根据id查询标签详情")
    public ResponseVO getShopTagsById(@PathVariable String shopId) {
        try {
            ShopTags shopById = tagsService.getShopTagsById(shopId);
            return ResponseVO.getSuccessResponseVo(shopById);
        } catch (Exception e) {
            e.printStackTrace();
            log.error(e.getMessage());
            throw new BusinessException("label_details_query_by_id_failed");
        }
    }
    @PostMapping("deleteShopTagsById/{shopId}")
    @ApiOperation("根据id删除标签")
    public ResponseVO deleteShopTagsById(@PathVariable String shopId) {
        try {
            Boolean aBoolean = tagsService.deleteShopTagsById(shopId);
            return aBoolean ? ResponseVO.getSuccessResponseVo(null) : ResponseVO.getFalseResponseVo(null);
        } catch (Exception e) {
            e.printStackTrace();
            log.error(e.getMessage());
            throw new BusinessException("label_delete_by_id_failed");
        }
    }


}
